import 'nprogress/nprogress.css'
import {RouteConfig} from 'vue-router'
import Layout from "@/core/layouts/Layout.vue";
import {compareProps, menuTreeToArray} from "@/core/utils/Utils";


/*
  *** 系统管理员，点击上传菜单到服务器
  *** 上传之后会覆盖服务端的修改数据
  *
  *  配置
  *
  path:'/index'                  必须使用全路径
  name:'router-name'             使用<keep-alive>时，name字段是必填字段，它也应与其组件的name属性匹配
  redirect:                      如果设置为“ noredirect”，则在单击面包屑时将不会触发任何重定向操作
  meta: {
       title: 'title'             子菜单和面包屑中显示的名称（推荐设置）
       icon: 'svg-name'           侧栏中显示的图标
       hidden: 1                  展示状态（1=展示，2=隐藏）
       alwaysShow: 2              1=始终显示根菜单  2=当子路由小于等于1时，隐藏根菜单',
       breadcrumb: 1              面包屑状态（1=展示，2=隐藏）',
       noCache: 1                 缓存（1=开启，2=关闭）
       addTag: 1                  打开新的路由，是否添加TAG，默认添加（1=添加，2=不添加）
       affix: 1                   标签是否允许关闭，默认可以关闭（1=可以关闭，2=不可以关闭）
       activeMenu:'/example/list' 如果设置了路径，则侧边栏将突出显示您设置的路径
  }
*/

/**
 * 企业微信路由
 * 需要放到全局路由内【...weiXinCompanyRouter】
 */
export const weiXinCompanyRouter: RouteConfig[] = [
    {
        path: '/weiXin/WxIndex',
        component: () => import('@/views/wx-xin/WxIndex.vue'),
        name: 'WxIndex',
        meta: {title: '高新人才数据统计系统', hidden: 2, sort: 100},
    },
    {
        path: '/weiXin/CompanyInfoWx',
        component: () => import('@/views/wx-xin/company-info/edit.vue'),
        name: 'CompanyInfoWx',
        meta: {title: '企业信息', hidden: 2, sort: 100},
    },
    {
        path: '/weiXin/DynamicHumanWx',
        component: () => import('@/views/wx-xin/dynamic-human-info/edit.vue'),
        name: 'DynamicHumanWx',
        meta: {title: '动态人力资源信息', hidden: 2, sort: 100},
    },
    {
        path: '/weiXin/InWorkHumanWx',
        component: () => import('@/views/wx-xin/in-work-human-info/edit.vue'),
        name: 'InWorkHumanWx',
        meta: {title: '员工基本情况', hidden: 2, sort: 100},
    },
];

/**
 * 企业路由
 */
export const companyRouter: RouteConfig[] = [
    {
        path: '/companyInfo',
        component: Layout,
        redirect: '/companyInfo/edit',
        meta: {title: '企业信息管理', icon: 'excel', sort: 7000},
        children: [
            {
                path: '/companyInfo/edit',
                component: () => import('@/views/company/company-info/edit.vue'),
                name: 'CompanyInfo',
                meta: {title: '企业信息', icon: 'excel', affix: 2, sort: 7000},
            }
        ]
    }, {
        path: '/dynamicHumanInfo',
        component: Layout,
        redirect: '/dynamicHumanInfo/edit',
        meta: {title: '动态人力资源管理', icon: 'excel', sort: 7001},
        children: [{
            path: '/dynamicHumanInfo/edit',
            component: () => import('@/views/company/dynamic-human-info/edit.vue'),
            name: 'DynamicHumanInfo',
            meta: {title: '动态人力资源信息', icon: 'excel', sort: 7001},
        }]
    }, {
        path: '/inWorkHumanInfo',
        component: Layout,
        redirect: '/inWorkHumanInfo/edit',
        meta: {title: '员工基本情况', icon: 'excel', sort: 7002},
        children: [{
            path: '/inWorkHumanInfo/edit',
            component: () => import('@/views/company/in-work-human-info/edit.vue'),
            name: 'InWorkHumanInfo',
            meta: {title: '员工基本情况', icon: 'excel', sort: 7002},
        }]
    },
];

/**
 * 政府角色路由
 */
export const governmentRouter: RouteConfig[] = [
    //企业管理-8000
    {
        path: '/government',
        component: Layout,
        redirect: '/government/company/list',
        meta: {title: '企业管理', icon: 'excel', sort: 8000},
        children: [
            {
                path: '/government/company/list',
                component: () => import('@/views/government/company/company-info/list.vue'),
                name: 'CompanyGList',
                meta: {title: '企业列表', affix: 2, sort: 8100},
            },
            {
                path: '/government/company/edit',
                component: () => import('@/views/government/company/company-info/edit.vue'),
                name: 'CompanyGEdit',
                meta: {title: '企业信息编辑', sort: 8100, hidden: 2},
            },
            {
                path: '/government/industryType/list',
                component: () => import('@/views/government/company/industry-type/list.vue'),
                name: 'IndustryTypeList',
                meta: {title: '行业类别', sort: 8100},
            },
            {
                path: '/government/dynamic/human/list',
                component: () => import('@/views/government/company/dynamic-human-info/list.vue'),
                name: 'DynamicHumanGList',
                meta: {title: '动态人力资源信息管理', icon: 'excel', sort: 8200, hidden: 2},
            },
            {
                path: '/government/dynamic/human/edit',
                component: () => import('@/views/government/company/dynamic-human-info/edit.vue'),
                name: 'DynamicHumanGEdit',
                meta: {title: '动态人力资源信息管理', icon: 'excel', sort: 8200, hidden: 2},
            },
            // {
            //     path: '/government/inWork/human/list',
            //     component: () => import('@/views/government/company/in-work-human-info/list.vue'),
            //     name: 'InWorkHumanGList',
            //     meta: {title: '员工基本情况管理', icon: 'excel', sort: 8300, hidden: 2},
            // },
            {
                path: '/government/inWork/human/edit',
                component: () => import('@/views/government/company/in-work-human-info/edit.vue'),
                name: 'InWorkHumanGEdit',
                meta: {title: '员工基本情况', icon: 'excel', sort: 8300, hidden: 2},
            },
            {
                path: '/government/recruitInfo/edit',
                component: () => import('@/views/government/company/recruit-Info/edit.vue'),
                name: 'RecruitInfoEdit',
                meta: {title: '用人单位招聘信息', icon: 'excel', sort: 8300, hidden: 2},
            }
        ]
    },
    //统计表-10000
    {
        path: '/statistics/table',
        component: Layout,
        redirect: '/statistics/table/DynamicHumanTable',
        meta: {title: '统计表管理', icon: 'excel', sort: 10000},
        children: [
            {
                path: '/statistics/table/DynamicHumanTable',
                component: () => import('@/views/government/statistics-table/DynamicHumanTable.vue'),
                name: 'DynamicHumanTable',
                meta: {title: '用工动态统计', sort: 10000},
            },
            {
                path: '/statistics/table/InWorkHumanTable',
                component: () => import('@/views/government/statistics-table/InWorkHumanTable.vue'),
                name: 'InWorkHumanTable',
                meta: {title: '员工基本情况', sort: 10000},
            },
            {
                path: '/statistics/table/RecruitInfoTable',
                component: () => import('@/views/government/statistics-table/RecruitInfoTable.vue'),
                name: 'RecruitInfoTable',
                meta: {title: '招聘情况反馈统计', sort: 10000},
            },
        ]
    },
    //统计图-11000
    {
        path: '/statistics/chart',
        component: Layout,
        redirect: '/statistics/chart/CompanyTypeChart',
        meta: {title: '统计图管理', icon: 'excel', sort: 11000},
        children: [
            {
                path: '/statistics/chart/CompanyTypeChart',
                component: () => import('@/views/government/statistics-chart/CompanyTypeChart.vue'),
                name: 'CompanyTypeChart',
                meta: {title: '企业性质统计图', sort: 11000},
            },
            {
                path: '/statistics/chart/IndustryTypeChart',
                component: () => import('@/views/government/statistics-chart/IndustryTypeChart.vue'),
                name: 'IndustryTypeChart',
                meta: {title: '行业比较统计图', sort: 11000},
            },
            {
                path: '/statistics/chart/UserPeopleChart',
                component: () => import('@/views/government/statistics-chart/UserPeopleChart.vue'),
                name: 'UserPeopleChart',
                meta: {title: '企业用工动态统计图', sort: 11000},
            },

        ]
    },

];

/**
 * 系统路由
 */
export const systemRouter: RouteConfig[] = [
    {
        path: '/system',
        component: Layout,
        redirect: '/system/dict',
        meta: {title: '系统配置', icon: 'excel', sort: 99999},
        children: [
            //用户
            {
                path: '/system/user/list',
                component: () => import('@/views/system/user/list.vue'),
                name: 'UserList',
                meta: {title: '用户管理', sort: 99999},
            },
            //角色
            {
                path: '/system/role/list',
                component: () => import('@/views/system/role/list.vue'),
                name: 'RoleList',
                meta: {title: '角色管理', sort: 99999},
            },
            //资源
            {
                path: '/system/resource/list',
                component: () => import('@/views/system/resource/list.vue'),
                name: 'ResourceList',
                meta: {title: '资源管理', sort: 99999},
            },
            //菜单
            {
                path: '/system/menu/list',
                component: () => import('@/views/system/menu/list.vue'),
                name: 'MenuList',
                meta: {title: '菜单管理', sort: 99999},
            },
            //字典
            {
                path: '/system/dict/list',
                component: () => import('@/views/system/dict/list.vue'),
                name: 'DictList',
                meta: {title: '字典管理', sort: 99999},
            }
        ]
    },
];

/**
 * 全局路由-任何角色都具备，不需要配置
 */
export const constantRoutes: RouteConfig[] = [
    {
        path: '/login',
        name: "Login",
        component: () => import('@/views/login/Login.vue'),
        meta: {hidden: 2}
    },
    {
        path: '/404',
        component: () => import('@/views/Index.vue'),
        meta: {hidden: 2}
    },
    {
        path: '/401',
        component: () => import('@/views/Index.vue'),
        meta: {hidden: 2}
    },
    {
        path: '/',
        component: Layout,
        redirect: '/index',
        meta: {hidden: 2, noCache: 2},
        children: [
            {
                path: '/index',
                component: () => import('@/views/Index.vue'),
                name: 'Index',
                // meta: { hidden: 2, icon: 'dashboard', affix: 1, sort: 1000}
                meta: {hidden: 2, noCache: 2, breadcrumb: 2, addTag: 2}
            },
            {
                path: '/RedirectBeforeView',
                component: () => import('@/views/RedirectBeforeView.vue'),
                name: 'RedirectBeforeView',
                // meta: { hidden: 2, icon: 'dashboard', affix: 1, sort: 1000}
                meta: {hidden: 2, noCache: 2, breadcrumb: 2, addTag: 2}
            },
        ]
    },
    {
        path: '/account',
        component: Layout,
        redirect: '/account/user/details',
        meta: {hidden: 2, title: "账号信息"},
        children: [{
            path: '/account/user/details',
            component: () => import('@/views/system/user/user-info/UserDetails.vue'),
            name: 'UserDetails',
            meta: {title: "账号详情", hidden: 2}
        }]
    },
];

/**
 * 全局路由对应的路径数组
 */
export const constantPaths = () => {
    let routers = JSON.parse(JSON.stringify(constantRoutes));
    let allMenu = menuTreeToArray(routers, []).sort(compareProps('path'));
    let paths: any = [];
    for (let m of allMenu) {
        if (m.path) {
            paths.push(m.path);
        }
    }
    return paths;
}

export const routerList: RouteConfig[] = [
    ...systemRouter,
    ...governmentRouter,
    ...companyRouter,
    ...weiXinCompanyRouter,
];
